package top.zhangjianyong.tools.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.zhangjianyong.tools.parm.UserLoginParm;
import top.zhangjianyong.tools.parm.UserRegParm;
import top.zhangjianyong.tools.service.api.RemindItemService;
import top.zhangjianyong.tools.service.api.UserService;
import top.zhangjianyong.tools.user.VerifyUser;
import top.zhangjianyong.tools.utils.ApiResponse;

import javax.annotation.Resource;

/**
 * @author ： zhangjianyong
 * @date ： 2021/11/1 14:30
 */
@SuppressWarnings("rawtypes")
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @VerifyUser(login = false)
    @PostMapping("/reg")
    public ApiResponse reg(@Validated @RequestBody UserRegParm userRegParm) throws Exception {
        return userService.reg(userRegParm);
    }

    @VerifyUser(login = false)
    @PostMapping("/login")
    public ApiResponse login(@RequestBody UserLoginParm userLoginParm) throws Exception {
        return userService.login(userLoginParm);
    }


}
